﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Web;
using carShop.Models;

namespace carShop.Data.EntityFramework
{
    public class CarConfiguration : EntityTypeConfiguration<Car>
    {
        public CarConfiguration()
        {
            HasRequired(c => c.Image);
            HasRequired(c => c.Video);
            Ignore(c => c.State);
        }
    }

    public class ImageConfiguration : EntityTypeConfiguration<Image>
    {
        public ImageConfiguration()
        {
            //put hasRequired attribute to  get the navigation property of the Car class
            //then create the one to many relationship
            HasRequired(i => i.Car)
            .WithMany(c => c.Image)
            .HasForeignKey(i => i.CarId);
            Ignore(c => c.State);
        }
    }

    public class VideoConfiguration : EntityTypeConfiguration<Video>
    {
        public VideoConfiguration()
        {
            HasRequired(v => v.Car)
            .WithMany(c => c.Video)
            .HasForeignKey(v => v.CarId);
            Ignore(c => c.State);
            
        }
    }
}